package navigation

import (
	"BookStack/pkg/utils"
	"time"
)

// NavigationListQueryParams 导航列表查询参数
type NavigationListQueryParams struct {
	Page     int    `form:"page" json:"page"`
	PageSize int    `form:"page_size" json:"page_size"`
	Position string `form:"position" json:"position"`
}

// NavigationListResponse 导航列表响应
type NavigationListResponse struct {
	Total int64                 `json:"total"`
	Items []*NavigationResponse `json:"items"`
}

// NavigationResponse 导航响应
type NavigationResponse struct {
	ID          uint      `json:"id"`
	Name        string    `json:"name"`
	URL         string    `json:"url"`
	Icon        string    `json:"icon"`
	Position    string    `json:"position"`
	ParentID    *uint     `json:"parent_id"`
	Order       int       `json:"order"`
	Status      int       `json:"status"`
	Target      string    `json:"target"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

// CreateNavigationRequest 创建导航请求
type CreateNavigationRequest struct {
	Name        string `json:"name" binding:"required,max=50"`
	URL         string `json:"url" binding:"required,max=255"`
	Icon        string `json:"icon" binding:"max=50"`
	Position    string `json:"position" binding:"required,max=20"`
	ParentID    *uint  `json:"parent_id"`
	Order       int    `json:"order"`
	Status      int    `json:"status"`
	Target      string `json:"target" binding:"max=20"`
	Description string `json:"description" binding:"max=255"`
}

// UpdateNavigationRequest 更新导航请求
type UpdateNavigationRequest struct {
	ID          uint   `json:"id" binding:"required"`
	Name        string `json:"name" binding:"required,max=50"`
	URL         string `json:"url" binding:"required,max=255"`
	Icon        string `json:"icon" binding:"max=50"`
	Position    string `json:"position" binding:"required,max=20"`
	ParentID    *uint  `json:"parent_id"`
	Order       int    `json:"order"`
	Status      int    `json:"status"`
	Target      string `json:"target" binding:"max=20"`
	Description string `json:"description" binding:"max=255"`
}

// UpdateStatusRequest 更新导航状态请求
type UpdateStatusRequest struct {
	ID     uint `json:"id" binding:"required"`
	Status int  `json:"status" binding:"required,oneof=0 1"`
}

// BatchOrderRequest 批量排序请求
type BatchOrderRequest struct {
	Items []OrderItem `json:"items" binding:"required,dive"`
}

// OrderItem 排序项
type OrderItem struct {
	ID    uint `json:"id" binding:"required"`
	Order int  `json:"order" binding:"required"`
}

// NavigationTreeResponse 导航树响应
type NavigationTreeResponse struct {
	ID          uint                      `json:"id"`
	Name        string                    `json:"name"`
	URL         string                    `json:"url"`
	Icon        string                    `json:"icon"`
	Position    string                    `json:"position"`
	Order       int                       `json:"order"`
	Status      int                       `json:"status"`
	Target      string                    `json:"target"`
	Description string                    `json:"description"`
	Children    []*NavigationTreeResponse `json:"children,omitempty"`
	CreatedAt   utils.JSONTime            `json:"created_at"`
	UpdatedAt   utils.JSONTime            `json:"updated_at"`
}

// DeleteNavigationRequest 删除导航请求
type DeleteNavigationRequest struct {
	ID uint `json:"id" binding:"required"`
}

// NavigationEvent 导航事件数据
type NavigationEvent struct {
	ID       uint   `json:"id"`
	Name     string `json:"name"`
	Position string `json:"position"`
}
